﻿using MediatR;
using SheepStorage.API.Application.Command.ProvinceCommand;
using SheepStorage.API.Application.Command.SheepManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.ProvinceHandlers
{
    public class ProvinceListCommandHandlers : IRequestHandler<ProvinceListCommand, Results<List<Province>>>
    {

        private readonly IProvinceService _provinceService;

        public ProvinceListCommandHandlers(IProvinceService provinceService)
        {
            _provinceService = provinceService;
        }


        /// <summary>
        /// 显示省份
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
      public async Task<Results<List<Province>>> Handle(ProvinceListCommand request, CancellationToken cancellationToken)
      {
            return Results<List<Province>>.DataResult(await _provinceService.GetProvinces());
      }
    }
}
